using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Messages.Entity
{
    [Table("Message", "", "Wicresoft.Messages.ConnectionString")]
    public class Message : Info
    {
        #region SQL column name consts
        public const string SQLCOL_MESSAGEID = "MessageID";
        public const string SQLCOL_CREATETIME = "CreateTime";
        public const string SQLCOL_MODULEID = "ModuleID";
        public const string SQLCOL_TITLE = "Title";
        public const string SQLCOL_TEXT = "Text";
        public const string SQLCOL_MESSAGESTATUS = "MessageStatus";
        public const string SQLCOL_LASTOPERATIONTIME = "LastOperationTime";
        public const string SQLCOL_SENDERNAME = "SenderName";
        public const string SQLCOL_SENDERDISPLAYNAME = "SenderDisplayName";
        public const string SQLCOL_RECEIVERS = "Receivers";
        public const string SQLCOL_SENDTIME = "SendTime";
        public const string SQLCOL_PROCESSSTATUS = "ProcessStatus";
        public const string SQLCOL_PROCESSTIME = "ProcessTime";
        public const string SQLCOL_PROCESSCOUNT = "ProcessCount";
        public const string SQLCOL_NOTIFYURL = "NotifyUrl";
        public const string SQLCOL_TAG = "Tag";
        public const string SQLCOL_NEEDFEEDBACK = "NeedFeedBack";
        public const string SQLCOL_TIMEOUT = "TimeOut";
        public const string SQLCOL_PRIORITY = "Priority";
        public const string SQLCOL_FEEDBACKSTATUS = "FeedBackStatus";
        public const string SQLCOL_FEEDBACKFORWARD = "FeedBackForward";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public Message() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public Message(Guid MessageID)
        {
            this.MessageID = MessageID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            MessageID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_MESSAGEID]);
            CreateTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_CREATETIME]);
            ModuleID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_MODULEID]);
            Title = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_TITLE]);
            Text = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_TEXT]);
            MessageStatus = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_MESSAGESTATUS]);
            LastOperationTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_LASTOPERATIONTIME]);
            SenderName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_SENDERNAME]);
            SenderDisplayName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_SENDERDISPLAYNAME]);
            Receivers = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_RECEIVERS]);
            SendTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_SENDTIME]);
            ProcessStatus = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_PROCESSSTATUS]);
            ProcessTime = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_PROCESSTIME]);
            ProcessCount = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_PROCESSCOUNT]);
            NotifyUrl = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_NOTIFYURL]);
            Tag = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_TAG]);
            NeedFeedBack = (bool)ObjectType.BooleanTypeHelper.Read(row[SQLCOL_NEEDFEEDBACK]);
            TimeOut = (DateTime)ObjectType.DateTimeTypeHelper.Read(row[SQLCOL_TIMEOUT]);
            Priority = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_PRIORITY]);
            FeedBackStatus = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_FEEDBACKSTATUS]);
            FeedBackForward = (bool)ObjectType.BooleanTypeHelper.Read(row[SQLCOL_FEEDBACKFORWARD]);
        }

        #region Properties
        #region Property <Guid> MessageID
        [Property("MessageID", 16, SqlDbType.UniqueIdentifier, false, true)]
        public Guid MessageID
        {
            get { return _MessageID; }
            set { _MessageID = value; }
        }
        private Guid _MessageID = Guid.Empty;
        #endregion

        #region Property <DateTime> CreateTime
        [Property("CreateTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime CreateTime
        {
            get { return _CreateTime; }
            set { _CreateTime = value; }
        }
        private DateTime _CreateTime = DateTime.MinValue;
        #endregion

        #region Property <Guid> ModuleID
        [Property("ModuleID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid ModuleID
        {
            get { return _ModuleID; }
            set { _ModuleID = value; }
        }
        private Guid _ModuleID = Guid.Empty;
        #endregion

        #region Property <string> Title
        [Property("Title", 2000, SqlDbType.NVarChar, false, false)]
        public string Title
        {
            get { return _Title; }
            set { _Title = value; }
        }
        private string _Title = null;
        #endregion

        #region Property <string> Text
        [Property("Text", 2147483646, SqlDbType.NText, false, false)]
        public string Text
        {
            get { return _Text; }
            set { _Text = value; }
        }
        private string _Text = null;
        #endregion

        #region Property <int> MessageStatus
        [Property("MessageStatus", 4, SqlDbType.Int, false, false)]
        public int MessageStatus
        {
            get { return _MessageStatus; }
            set { _MessageStatus = value; }
        }
        private int _MessageStatus = int.MinValue;
        #endregion

        #region Property <DateTime> LastOperationTime
        [Property("LastOperationTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime LastOperationTime
        {
            get { return _LastOperationTime; }
            set { _LastOperationTime = value; }
        }
        private DateTime _LastOperationTime = DateTime.MinValue;
        #endregion

        #region Property <string> SenderName
        [Property("SenderName", 100, SqlDbType.NVarChar, false, false)]
        public string SenderName
        {
            get { return _SenderName; }
            set { _SenderName = value; }
        }
        private string _SenderName = null;
        #endregion

        #region Property <string> SenderDisplayName
        [Property("SenderDisplayName", 100, SqlDbType.NVarChar, false, false)]
        public string SenderDisplayName
        {
            get { return _SenderDisplayName; }
            set { _SenderDisplayName = value; }
        }
        private string _SenderDisplayName = null;
        #endregion

        #region Property <string> Receivers
        [Property("Receivers", 2147483646, SqlDbType.NText, false, false)]
        public string Receivers
        {
            get { return _Receivers; }
            set { _Receivers = value; }
        }
        private string _Receivers = null;
        #endregion

        #region Property <DateTime> SendTime
        [Property("SendTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime SendTime
        {
            get { return _SendTime; }
            set { _SendTime = value; }
        }
        private DateTime _SendTime = DateTime.MinValue;
        #endregion

        #region Property <int> ProcessStatus
        [Property("ProcessStatus", 4, SqlDbType.Int, false, false)]
        public int ProcessStatus
        {
            get { return _ProcessStatus; }
            set { _ProcessStatus = value; }
        }
        private int _ProcessStatus = int.MinValue;
        #endregion

        #region Property <DateTime> ProcessTime
        [Property("ProcessTime", 16, SqlDbType.DateTime, false, false)]
        public DateTime ProcessTime
        {
            get { return _ProcessTime; }
            set { _ProcessTime = value; }
        }
        private DateTime _ProcessTime = DateTime.MinValue;
        #endregion

        #region Property <int> ProcessCount
        [Property("ProcessCount", 4, SqlDbType.Int, false, false)]
        public int ProcessCount
        {
            get { return _ProcessCount; }
            set { _ProcessCount = value; }
        }
        private int _ProcessCount = int.MinValue;
        #endregion

        #region Property <string> NotifyUrl
        [Property("NotifyUrl", 2147483646, SqlDbType.NText, false, false)]
        public string NotifyUrl
        {
            get { return _NotifyUrl; }
            set { _NotifyUrl = value; }
        }
        private string _NotifyUrl = null;
        #endregion

        #region Property <string> Tag
        [Property("Tag", 2147483646, SqlDbType.NText, false, false)]
        public string Tag
        {
            get { return _Tag; }
            set { _Tag = value; }
        }
        private string _Tag = null;
        #endregion

        #region Property <bool> NeedFeedBack
        [Property("NeedFeedBack", 1, SqlDbType.Bit, false, false)]
        public bool NeedFeedBack
        {
            get { return _NeedFeedBack; }
            set { _NeedFeedBack = value; }
        }
        private bool _NeedFeedBack = false;
        #endregion

        #region Property <DateTime> TimeOut
        [Property("TimeOut", 16, SqlDbType.DateTime, false, false)]
        public DateTime TimeOut
        {
            get { return _TimeOut; }
            set { _TimeOut = value; }
        }
        private DateTime _TimeOut = DateTime.MinValue;
        #endregion

        #region Property <int> Priority
        [Property("Priority", 4, SqlDbType.Int, false, false)]
        public int Priority
        {
            get { return _Priority; }
            set { _Priority = value; }
        }
        private int _Priority = int.MinValue;
        #endregion

        #region Property <int> FeedBackStatus
        [Property("FeedBackStatus", 4, SqlDbType.Int, false, false)]
        public int FeedBackStatus
        {
            get { return _FeedBackStatus; }
            set { _FeedBackStatus = value; }
        }
        private int _FeedBackStatus = int.MinValue;
        #endregion

        #region Property <bool> FeedBackForward
        [Property("FeedBackForward", 1, SqlDbType.Bit, false, false)]
        public bool FeedBackForward
        {
            get { return _FeedBackForward; }
            set { _FeedBackForward = value; }
        }
        private bool _FeedBackForward = false;
        #endregion
        #endregion




    }
}
